﻿<UserControl x:Class="RegisterModule.Views.RegisterView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
             xmlns:Helper="clr-namespace:Resources.Class;assembly=Resources"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             mc:Ignorable="d" Height="250" Width="380">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--普通按钮样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/ButtonStyle.xaml"/>
                <!--TextBox样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/TextBoxStyle.xaml"/>
                <!--PasswordBox样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/PwBoxStyle.xaml"/>
                <!--ListBox样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/ListBoxStyle.xaml"/>
                <!--ScrollViewer样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/ScrollViewerStyle.xaml"/>
                <!--总颜色样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/Themes/Colors.xaml"/>
                <!--总文字样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/Themes/Texts.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border x:Name="backGround" Background="{x:Null}" BorderBrush="{StaticResource border}" BorderThickness="1">
        <Grid>
            <Grid.Resources>
                <XmlDataProvider x:Key="xmlDef" Source="pack://application:,,,/Resources;component/XmlFile/UserPic.xml" XPath="Data/pictype/d_image"/>
                <XmlDataProvider x:Key="xmlBoy" Source="pack://application:,,,/Resources;component/XmlFile/UserPic.xml" XPath="Data/pictype/b_image"/>
                <XmlDataProvider x:Key="xmlGirl" Source="pack://application:,,,/Resources;component/XmlFile/UserPic.xml" XPath="Data/pictype/g_image"/>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="32"/>
                <RowDefinition Height="20"/>
            </Grid.RowDefinitions>
            <TextBlock Width="Auto" TextAlignment="Center" Text="{StaticResource register_text}" Foreground="{StaticResource bg_text}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Bottom" Grid.Row="0"/>
            <Grid Grid.Row="1">
                <TextBox x:Name="cardWord" Text="{Binding 
                    Path=CardWord, 
                    UpdateSourceTrigger=PropertyChanged, 
                    ValidatesOnDataErrors=True,
                    ValidatesOnExceptions=True}" Style="{StaticResource TextCardStyle}" HorizontalAlignment="Left" Height="27" Margin="35,22,0,0" VerticalAlignment="Top" Width="216" FontSize="16"/>
                <TextBox x:Name="userName" Text="{Binding
                    Path=UserName, 
                    UpdateSourceTrigger=PropertyChanged, 
                    ValidatesOnDataErrors=True, 
                    ValidatesOnExceptions=True}" Style="{StaticResource TextNameStyle}" HorizontalAlignment="Left" Height="27" Margin="35,54,0,0" VerticalAlignment="Top" Width="216" FontSize="16"/>
                <PasswordBox x:Name="newPsw" Helper:PassWordBing.Attach="True" Helper:PassWordBing.Password="{Binding
                    Path=NewPsw,
                    Mode=TwoWay,
                    UpdateSourceTrigger=PropertyChanged,
                    ValidatesOnDataErrors=True,
                    ValidatesOnExceptions=True}"  Style="{StaticResource PwBoxStyle}" HorizontalAlignment="Left" Height="27" Margin="35,86,0,0" VerticalAlignment="Top" Width="140"/>
                <PasswordBox x:Name="conPsw" Helper:PassWordBing.Attach="True" Helper:PassWordBing.Password="{Binding
                    Path=ConPsw,
                    Mode=TwoWay,
                    UpdateSourceTrigger=PropertyChanged,
                    ValidatesOnDataErrors=True,
                    ValidatesOnExceptions=True}" Style="{StaticResource RePwBoxStyle}" HorizontalAlignment="Left" Height="27" Margin="202,86,0,0" VerticalAlignment="Top" Width="140"/>
                <TextBox x:Name="userMail" Text="{Binding 
                    Path=UserMail, 
                    UpdateSourceTrigger=PropertyChanged, 
                    ValidatesOnDataErrors=True,
                    ValidatesOnExceptions=True}" Style="{StaticResource TextRMailStyle}" HorizontalAlignment="Left" Height="27" Margin="35,118,0,0" VerticalAlignment="Top" Width="216" FontSize="16"/>
                <TextBox x:Name="registerNum" Text="{Binding 
                    Path=Num, 
                    UpdateSourceTrigger=PropertyChanged, 
                    ValidatesOnDataErrors=True,
                    ValidatesOnExceptions=True}" Style="{StaticResource TextRegNumStyle}" HorizontalAlignment="Left" Height="27" Margin="279,118,0,0" VerticalAlignment="Top" Width="63" FontSize="16"/>
                <Rectangle x:Name="userPic" Stroke="{StaticResource border}" Margin="281,21,37,85" RadiusX="3" RadiusY="3" ToolTip="点击切换" Cursor="Hand">
                    <Rectangle.Fill>
                        <ImageBrush ImageSource="{Binding ImageUrl}"/>
                    </Rectangle.Fill>
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="MouseLeftButtonUp">
                            <i:InvokeCommandAction Command="{Binding ChangeCommand}" CommandParameter="{Binding ElementName=pic_Popup}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Rectangle>
            </Grid>
            <Border Height="32" Background="{StaticResource bg_module}" Grid.Row="2">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10"/>
                        <ColumnDefinition Width="30"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="130"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="30"/>
                        <ColumnDefinition Width="10"/>
                    </Grid.ColumnDefinitions>
                    <Path Width="30" Height="20" Stretch="Fill" Fill="{StaticResource arrow}" Data="F1 M 39.8307,37.6042L 36.6641,34.4375L 25.1849,23.3542L 35.4766,23.3542L 50.5182,37.6042L 35.4766,51.8542L 25.1849,51.8542L 36.6641,40.7708L 39.8307,37.6042 Z " Grid.Column="5"/>
                    <Path Width="30" Height="20" Stretch="Fill" Fill="{StaticResource arrow}" Data="F1 M 35.8724,37.6042L 39.0391,40.7708L 50.5182,51.8542L 40.2266,51.8542L 25.1849,37.6041L 40.2266,23.3542L 50.5182,23.3542L 39.0391,34.4375L 35.8724,37.6042 Z " Grid.Column="1"/>
                    <StackPanel Orientation="Horizontal" Grid.Column="3">
                        <Button Width="65" Content="提交注册" FontSize="14" Style="{StaticResource TimerBtnStyle}" Command="{Binding RegisterCommand}"/>
                        <Button Width="65" Content="点击获取" FontSize="14" Style="{StaticResource TimerBtnStyle}"
                                Command="{Binding ApplyCommand}" CommandParameter="{Binding ElementName=userMail,Path=Text}"/>
                    </StackPanel>
                </Grid>
            </Border>
            <Popup x:Name="pic_Popup" Height="300" Width="{StaticResource popUp_w}" StaysOpen="False" Placement="Mouse" PopupAnimation="Fade"  AllowsTransparency="True">
                <Border x:Name="bd_Popup" CornerRadius="3" BorderBrush="Gray" BorderThickness="1" Background="White">
                    <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" Template="{DynamicResource ScrollViewerStyle}">
                        <StackPanel>
                            <TextBlock Text=" 默认头像" Margin="0,5,0,0"/>
                            <ListBox DataContext="{Binding Source={StaticResource xmlDef}}" ItemsSource="{Binding}" Style="{StaticResource template}"
                  ItemContainerStyle="{StaticResource itemTemplate}" HorizontalAlignment="Left" VerticalAlignment="Top" Height="{StaticResource def_h}" Width="{StaticResource listBox_w}" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="0" >
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Border Name="border" Width="50" Height="50" CornerRadius="4" BorderBrush="LightGray" BorderThickness="1">
                                                <Rectangle x:Name="rect" Width="48" Height="48" RadiusX="3" RadiusY="3" StrokeThickness="1" Stroke="White" Tag="{Binding ElementName=registerView,Path=DataContext}" >
                                                    <Rectangle.Fill>
                                                        <ImageBrush ImageSource="{Binding XPath=@src}"/>
                                                    </Rectangle.Fill>
                                                    <i:Interaction.Triggers>
                                                        <i:EventTrigger EventName="MouseLeftButtonDown">
                                                            <i:InvokeCommandAction Command="{Binding Path=DataContext.SelectCommand,
                                                                RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}}}" 
                                                                                   CommandParameter="{Binding ElementName=rect}" />
                                                        </i:EventTrigger>
                                                    </i:Interaction.Triggers>
                                                </Rectangle>
                                            </Border>
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem},Path=IsMouseOver}" Value="True">
                                                <Setter TargetName="border" Property="BorderBrush" Value="#770EC6D8"/>
                                                <Setter TargetName="rect" Property="Stroke" Value="#FF0EC6D8"/>
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                            <TextBlock Text=" 男生头像"/>
                            <ListBox DataContext="{Binding Source={StaticResource xmlBoy}}"  ItemsSource="{Binding}" Style="{StaticResource template}"
                  ItemContainerStyle="{StaticResource itemTemplate}" HorizontalAlignment="Left" VerticalAlignment="Top" Height="{StaticResource boy_h}" Width="{StaticResource listBox_w}" Background="{x:Null}" >
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Border Name="border" Width="50" Height="50" CornerRadius="4" BorderBrush="LightGray" BorderThickness="1">
                                                <Rectangle x:Name="rect" Width="48" Height="48" RadiusX="3" RadiusY="3" StrokeThickness="1" Stroke="White">
                                                    <Rectangle.Fill>
                                                        <ImageBrush ImageSource="{Binding XPath=@src}"/>
                                                    </Rectangle.Fill>
                                                    <i:Interaction.Triggers>
                                                        <i:EventTrigger EventName="MouseLeftButtonDown">
                                                            <i:InvokeCommandAction Command="{Binding Path=DataContext.SelectCommand,
                                                                RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}}}" 
                                                                                   CommandParameter="{Binding ElementName=rect}" />
                                                        </i:EventTrigger>
                                                    </i:Interaction.Triggers>
                                                </Rectangle>
                                            </Border>
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem},Path=IsMouseOver}" Value="True">
                                                <Setter TargetName="border" Property="BorderBrush" Value="#770EC6D8"/>
                                                <Setter TargetName="rect" Property="Stroke" Value="#FF0EC6D8"/>
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                            <TextBlock Text=" 女生头像"/>
                            <ListBox DataContext="{Binding Source={StaticResource xmlGirl}}" ItemsSource="{Binding}" Style="{StaticResource template}"
                  ItemContainerStyle="{StaticResource itemTemplate}" HorizontalAlignment="Left" VerticalAlignment="Top" Height="{StaticResource girl_h}" Width="{StaticResource listBox_w}" Background="{x:Null}" >
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Border Name="border" Width="50" Height="50" CornerRadius="4" BorderBrush="LightGray" BorderThickness="1">
                                                <Rectangle x:Name="rect" Width="48" Height="48" RadiusX="3" RadiusY="3" StrokeThickness="1" Stroke="White">
                                                    <Rectangle.Fill>
                                                        <ImageBrush ImageSource="{Binding XPath=@src}"/>
                                                    </Rectangle.Fill>
                                                    <i:Interaction.Triggers>
                                                        <i:EventTrigger EventName="MouseLeftButtonDown">
                                                            <i:InvokeCommandAction Command="{Binding Path=DataContext.SelectCommand,
                                                                RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}}}" 
                                                                                   CommandParameter="{Binding ElementName=rect}" />
                                                        </i:EventTrigger>
                                                    </i:Interaction.Triggers>
                                                </Rectangle>
                                            </Border>
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem},Path=IsMouseOver}" Value="True">
                                                <Setter TargetName="border" Property="BorderBrush" Value="#770EC6D8"/>
                                                <Setter TargetName="rect" Property="Stroke" Value="#FF0EC6D8"/>
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </StackPanel>
                    </ScrollViewer>
                </Border>
            </Popup>
        </Grid>
    </Border>
</UserControl>
